import re

import datetime

item = {'asin': 'B001QA4TQO',
        'amazoncommentid': '/gp/customer-reviews/R32XYPESCZXOGY/ref=cm_cr_arp_d_rvw_ttl?ie=UTF8&ASIN=B001QA4TQO',
        'participant': '0',
        'helpful': '4 Was this review helpful to you?',
        'AppName': '11',
        'grade': '1.0 out of 5 stars',
        'author': 'Manx Shearwater',
        'content': "Mine was defective, so I returned it and got a full refund. All's well that ends well. The blu-ray feature initially worked, but the drive was unable to write CD-R's and had other problems.",
        'authorid': '/gp/profile/amzn1.account.AEW26AGGGNXLPMLVJ3XNDVGKAGWA/ref=cm_cr_arp_d_pdp?ie=UTF8',
        'commenttype': 'Verified Purchase',
        'date': 'on November 1, 2009',
        'title': 'Defective drive.'}

matchobj = re.search('/gp/customer-reviews/(.*?)/',item['amazoncommentid'],flags=0)
if matchobj != None:
    print matchobj.group(), matchobj.group(1)
matchobj = re.match('^Was',item['helpful'],flags=0)
if matchobj != None:
    print matchobj.group()
else:
    matchobj = re.match('^(.*?) Was', item['helpful'], flags=0)
    if matchobj != None:
        print matchobj.group(), matchobj.group(1)

matchobj = re.match('^(.*?) out',item['grade'],flags=0)
if matchobj != None:
    print matchobj.group(),matchobj.group(1)
matchobj = re.search('/gp/profile/(.*?)/',item['authorid'],flags=0)
if matchobj != None:
    print matchobj.group(),matchobj.group(1)

matchobj = re.search('on (.*)',item['date'],flags=0)
if matchobj != None:
    print matchobj.group(),matchobj.group(1)
    print datetime.datetime.strptime(matchobj.group(1),'%B %d, %Y')

dir()









